<?php

function model_works($bdd) {

    $results = $bdd->query('
       SELECT  u.user_name , u.user_surname , u.id_user,w.id_work, w.user_id author_user ,w.work_name ,w.work_description,w.img_type
       FROM users u
       INNER JOIN works w
       ON  u.id_user=w.user_id ');

    return $results;
}

function model_one_work($bdd, $details) {

    $results = $bdd->query('
       SELECT  u.user_name , u.user_surname,  u.id_user,w.id_work, w.user_id, w.work_like ,w.work_name ,w.work_description,w.img_type,w.img_type2
       FROM users u
       INNER JOIN works w
       ON  u.id_user=w.user_id
       WHERE id_work = ' . $details . '');

    return $results;
}

function select_one_region($bdd,$region) {

    $results = $bdd->query('
       SELECT  u.user_name , u.user_surname , u.id_user,w.id_work, w.user_id author_user ,w.work_name ,w.work_description,w.img_type
       FROM users u
       INNER JOIN works w
       ON  u.id_user=w.user_id
       WHERE id_region = ' . $region . '');

    return $results;
}

function add_like($bdd, $details, $like) {

    $req = $bdd->prepare('UPDATE works SET work_like = :work_like WHERE id_work = ' . $details . '');
    $req->execute(array(
        'work_like' => $like+1));
}

f
?>